import React from 'react'
import { BrowserRouter,useRoutes } from 'react-router-dom'
import routes from '~react-pages'
import './App.css'

const App = () =>
{
    //路由列表
    const Routes = () =>
    {
        //设置全局跳转路由函数
        React.navigate = useNavigate()

        //logation.pathname
        const {pathname} = useLocation()

        //路由守卫
        if(!React.RouterRules.includes(pathname)) check()
        //返回自动生成的路由列表
        return useRoutes(routes)
    }

    //登录判断(路由守卫)
    const check = async () =>
    {
        let id = React.business.
    }

    //页面加载中loading
    const fallback = () => (<React.UI.AutoCenter><React.UI.DotLoading color='primary'/></React.UI.AutoCenter>)

    return (
        <BrowserRouter future={{v7_startTransition: true, v7_relativeSplatPath: true}}>
            <React.Suspense future={fallback()}>
                <Routes />
            </React.Suspense>
        </BrowserRouter>
    )
}

export default App
